package tcp_net.mail.pop3.commands;

import tcp_net.ReplyMessage;
import tcp_net.mail.pop3.commands.debug.DebugInfo;
import java.util.List;
import java.util.ArrayList;

/**
	This class provides a reply command at POP3 level
	@author J. Okuno
*/
public class POP3ReplyMessage extends ReplyMessage
{
	/**
		true if the command is acceptable
	*/
	private boolean okay;
	
	/**
		A reply message
	*/
	private String msg;
	
	/**
		Init the class
		@param ok an acceptable response
		@param m a reply message
	*/
	public POP3ReplyMessage(boolean ok, String m) 
	{
		okay = ok;
		msg = m;
	}
	
	/**
		Init the class
		@param ok an acceptable response
	*/
	public POP3ReplyMessage(boolean ok) 
	{
		this(ok,"");
	}
	
	/**
		This method executes a defined command
		@return a list of reply messages in a string format
	*/
	public List<String> execute() 
	{
		List<String> reply_msgs = new ArrayList<String>();
		String response = "";
		
		if(okay) 
		{ 
			response = "+OK"; 
		}
		else
		{
			response = "-ERR";
		}
		
		if(msg.equals("")) { reply_msgs.add(response); }
		else { reply_msgs.add(response + " " + msg); }
		
		return reply_msgs;
	}
}